/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-07-26 17:45:29
 * Copyright (c) 2015- -版权所有
 */
package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.BpDeviceFacilityStopRecoverRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;


/**
 * BpDeviceFacilityStopRecoverRecordDao
 */
public interface BpDeviceFacilityStopRecoverRecordDao extends JpaRepository<BpDeviceFacilityStopRecoverRecord, Long>, QuerydslPredicateExecutor<BpDeviceFacilityStopRecoverRecord> {
    public Page<BpDeviceFacilityStopRecoverRecord> findAll(Specification<BpDeviceFacilityStopRecoverRecord> spec, Pageable pageable);

    public BpDeviceFacilityStopRecoverRecord save(BpDeviceFacilityStopRecoverRecord bean);

    public void delete(BpDeviceFacilityStopRecoverRecord bean);

    @Query(value = "SELECT COUNT(*) FROM wwyt_bp_device_facility_stop_recover_record WHERE TYPE = ?1 AND DEVICE_FACILITY_ID =?2 AND id !=?3 AND delete_flag = '0'", nativeQuery = true)
    int countByTypeAndDacilityIdAndIdNotEq(String s, Long facilityId, Long recordId);
}
